package com.cx.mall.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cx.mall.demo.mapper.DemoUserReceiveAddressMapper;
import com.cx.mall.demo.model.UserReceiveAddress;
import com.cx.mall.demo.service.IDemoUserReceiveAddressSrevice;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("demoUserReceiveAddressServiceImpl")
public class DemoUserReceiveAddressServiceImpl extends ServiceImpl<DemoUserReceiveAddressMapper, UserReceiveAddress> implements IDemoUserReceiveAddressSrevice {
    @Override
    public List<UserReceiveAddress> selectByUserId(Long userId) {
        LambdaQueryWrapper<UserReceiveAddress> queryWrapper = new LambdaQueryWrapper<>();
        List<UserReceiveAddress> list = baseMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public List<UserReceiveAddress> selectByCity(String city) {
        LambdaQueryChainWrapper<UserReceiveAddress> queryChainWrapper = new LambdaQueryChainWrapper<>(baseMapper);
        List<UserReceiveAddress> list = queryChainWrapper.eq(UserReceiveAddress::getCity,city).list();
        return list;
    }
}
